package metric

import (
	"aicloud/monitor-apiserver/pkg/util"
	_const "aicloud/monitor-apiserver/pkg/util/const"
	"github.com/prometheus/client_golang/api"
	v1 "github.com/prometheus/client_golang/api/prometheus/v1"
)

var (
	PromApiClient v1.API
)

func InitPrometheusClient() {
	var (
		err error
	)
	prometheusUrl := util.GetEnvOrDefault(_const.METRIC_ADDRESS_ENV, "http://localhost:9090")
	promClient, err := api.NewClient(api.Config{Address: prometheusUrl})
	if err != nil {
		util.GetLogger().Fatalf("init prometheus client error: %v", err)
	}
	PromApiClient = v1.NewAPI(promClient)
}
